<?php

namespace Home\Controller;
use Think\Controller;

//微信配置地址
class SpecialofferController extends  BaseController {
    
    /**
     * 前台控制器初始化 
     */
     function _initialize(){
       parent::_initialize();
    }
    
    public function index(){
      $this->assign('pagetitle','特卖商品');
         $this->display();

    }
    public function selectlist(){  
       $msg=M("wx_salelist");
         if (!empty($_GET['pageNow'])||!empty($_GET['pageSize'])) {
            $pageNow = $_GET['pageNow'];
            $pageSize =$_GET['pageSize'];
        } else {
            $pageNow = 1;
             $pageSize = 10;
        }
         $pageNow = $_GET['pageNow'];
          $count =$msg->alias("a")->join(" left join ki_wx_sale b on a.saleid=b.saleid")->join(" left join ki_goods c on a.goodsid=c.goods_id")->where($where)->count(); // 查询满足要求的总记录数
          $numPage =ceil($count/$pageSize) ;
          if($pageNow > $numPage){
            echo "";
          }
        $pages = $pageSize * ($pageNow - 1)<=0 ? 0 :$pageSize * ($pageNow - 1) ;
        $where['isactive'] = '1';


        $ret=$msg->alias("a")->field("a.*,b.salename,c.goods_name,c.goods_thumb,c.goods_weight ")->join(" left join ki_wx_sale b on a.saleid=b.saleid")->join(" left join ki_goods c on a.goodsid=c.goods_id")->where($where)->limit( $pages,$pageSize )->order("a.createtime desc")->select(); 

       if($ret != false){
        echo json_encode($ret);
       }else{
        echo "";
       }
   
    
   
}
}
?>